﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class login : System.Web.UI.UserControl
{
    DataTableDataContext db = new DataTableDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        //从数据库的superType和subType表中导入数据到menu控件中
        if (!IsPostBack)
        {
            var superTypes = from s in db.SuperType select s;
            var subTypes = from sub in db.SubType select sub;

            foreach (var superType in superTypes)
            {
                MenuItem item = new MenuItem();
                item.Text = superType.superTypeName;
                item.Value ="superType|"+Convert.ToString(superType.superTypeId);
                ShowMenu.Items.Add(item);
              
                foreach (var subType in subTypes)
                {
                    MenuItem childItem = new MenuItem();
                    childItem.Text = subType.subTypeName;
                    if (subType.superTypeId == superType.superTypeId)
                    {
                        item.ChildItems.Add(childItem);
                        childItem.Value ="subType|"+Convert.ToString(subType.subTypeId);
                    }
                }
            }
        }

    }
    protected void MenuClick(object sender, MenuEventArgs e)
    {
        Server.Transfer("~/Customer/showBook.aspx?id=" + ShowMenu.SelectedItem.Value);
        //Application["id"] = ShowMenu.SelectedItem.Value;
    }
}